﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HISModel;
using System.Data;
using System.Data.SqlClient;
using Newtonsoft.Json;
namespace HISDAL
{
    public class DoctorDAL
    {
        SqlConnection conn = new SqlConnection("Data Source=169.254.82.63;Initial Catalog=HospitalSystem;User ID=sa;password=asd_123");
        /// <summary>
        /// 显示当前登录医生
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public List<T_Doctor> ShowInfo(string name)
        {
            conn.Open();
            string sql = "select * from T_Doctor where Doctor_Name='"+name+"'";
            SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
            DataTable dt = new DataTable();
            sda.Fill(dt);
            var str = JsonConvert.SerializeObject(dt);
            return JsonConvert.DeserializeObject<List<T_Doctor>>(str);
        }
        /// <summary>
        /// 显示挂号当前医生的病人
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public List<Gh_Table> ShowghInfo(string name)
        {
            conn.Open();
            string sql = "SELECT dbo.Gh_Table.* FROM dbo.Gh_Table INNER JOIN dbo.T_Doctor ON dbo.T_Doctor.Doctor_ID=dbo.Gh_Table.Doctor_ID WHERE dbo.T_Doctor.Doctor_Name='"+name+"'";
            SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
            DataTable dt = new DataTable();
            sda.Fill(dt);
            var str = JsonConvert.SerializeObject(dt);
            return JsonConvert.DeserializeObject<List<Gh_Table>>(str);
        }
    }
}
